import axios from './axios'
import { UserLogin, AuthList, UserList, RoleList, UserAdd, UserEdit, UserDel, AuthAdd, AuthEdit, AuthDelete, RoleEdit, RoleAdd, RoleGetOne, RoleDel, DishList, CatList, DishAdd, DishDel, DishEdit, DishgetOne, CatAdd, CatDel, CatEdit, AuthStatus, UserStatus, DataCount, TableData } from './api'

// 请求表格数据
export function tableData() {
    return axios(TableData)
}

// 统计数据
export function dataCount() {
    return axios(DataCount)
}

// 修改用户状态
export function userStatus(id) {
    return axios(UserStatus + '/' + id,{
        method:'put',
    })
}

// 修改权限状态
export function authStatus(id) {
    return axios(AuthStatus + '/' + id,{
        method:'put',
    })
}

// 商品修改
export function catEdit(data) {
    // console.log(data);
    return axios(CatEdit + '/' + data.id,{
        method:'put',
        data
    })
}

// 分类删除
export function catDel(id) {
    return axios(CatDel + '/' + id,{
        method:'delete',
    })
}

// 分类添加
export function catAdd(data) {
    // console.log(data);
    return axios(CatAdd,{
        method:'post',
        data
    })
}

// 查找一个商品
export function dishgetOne(id) {
    return axios(DishgetOne + '/' + id,{
        method:'get',
    })
}

// 商品修改
export function dishEdit(data) {
    // console.log(data);
    return axios(DishEdit + '/' + data._id,{
        method:'put',
        data
    })
}

// 商品删除
export function dishDel(data) {
    return axios(DishDel + '/' + data._id,{
        method:'delete',
    })
}

// 商品添加
export function dishAdd(data) {
    // console.log(data);
    return axios(DishAdd,{
        method:'post',
        data
    })
}

// 分类列表
export function catList() {
    return axios(CatList)
}

// 商品列表
export function dishList() {
    return axios(DishList)
}

// 用户删除
export function roleDel(data) {
    return axios(RoleDel + '/' + data._id,{
        method:'delete',
    })
}

// 查找一个角色
export function roleGetOne(id) {
    return axios(RoleGetOne + '/' + id,{
        method:'get',
    })
}

// 角色添加
export function roleAdd(data) {
    console.log(data);
    return axios(RoleAdd,{
        method:'post',
        data
    })
}

// 角色修改
export function roleEdit(data) {
    // console.log(data);
    return axios(RoleEdit + '/' + data.id,{
        method:'put',
        data
    })
}

// 用户删除
export function authDelete(data) {
    return axios(AuthDelete + '/' + data._id,{
        method:'delete',
    })
}

// 权限修改
export function authEdit(data) {
    console.log(data);
    return axios(AuthEdit + '/' + data._id,{
        method:'put',
        data
    })
}

// 权限添加
export function authAdd(data) {
    // console.log(data);
    return axios(AuthAdd,{
        method:'post',
        data
    })
}

// 用户删除
export function userDel(data) {
    return axios(UserDel + '/' + data._id,{
        method:'delete',
    })
}

// 用户修改
export function userEdit(data) {
    console.log(data);
    return axios(UserEdit + '/' + data._id,{
        method:'put',
        data
    })
}

// 用户添加
export function userAdd(data) {
    return axios(UserAdd,{
        method:'post',
        data
    })
}

// 角色列表
export function roleList() {
    return axios(RoleList)
}

// 用户列表
export function userList() {
    return axios(UserList)
}

// 登录
export function userLogin(data){
    return axios(UserLogin, {
        method: 'post',
        data
    })
}

// 权限列表
export function authList() {
    return axios(AuthList)
}
